@extends('Share/home')
<?php
$title='供应商合同管理';
$nav_t='系统管理';
$nav_m='供应商合同管理';
?>
@section('demand-body')
<style>
.sContract-box{
   width: 1280px;
   background: #f6f6f6;
   border-top: 2px solid #b2cff0;
   border-bottom: 1px solid #b2cff0;
   margin: 0 auto;
   font-size: 14px;
}
 
/* 合同名字以及有效时间开始@dongdong */
.sContract-box-nametime{
   margin: 32px 0 16px 90px;
   overflow: hidden;
}
.sContract-nametime-name{
   overflow: hidden;
   float: left;
}
.sContract-name-p{
   float: left;
   color: #292929;
   line-height: 30px;
}
.sContract-name-text{
   margin-left: 24px;
   border: 1px solid #c9c9c9;
   width: 178px;
   height: 30px;    overflow: hidden;
   font-size: 14px;
}
.sContract-nametime-time{
   overflow: hidden;
   float: left;
   margin-left: 70px;
}
.sContract-time-p{
   float: left;
   font-size: 14px;
   color: #292929;
   line-height: 30px;
}
.sContract-time-start{
   float: left;
   width: 126px;
   height: 30px;
   border: 1px solid #c9c9c9;
   margin-left: 10px;
}
.sContract-time-conn{
   float: left;
   margin: 7px 10px 0 10px;
   font-weight: bold;
}
.sContract-time-end{
   float: left;
   width: 126px;
   height: 30px;
   border: 1px solid #c9c9c9;
}
/* 合同名字以及有效时间结束@dongdong */
 
/* 合同名字开始@dongdong */
.sContract-box-nametime{
   margin: 32px 0 16px 90px;
   overflow: hidden;
}
.sContract-nametime-name{
   overflow: hidden;
   float: left;
}
.sContract-name-p{
   float: left;
   color: #292929;
   line-height: 30px;
}
.sContract-name-text{
   margin-left: 24px;
   border: 1px solid #c9c9c9;
   width: 178px;
   height: 30px;    overflow: hidden;
   font-size: 14px;
}
/* 合同名字结束@dongdong */
 
/* 合同详情开始@dongdong */
.sContract-box-item{
   width: 1170px;
   margin-left: 110px;
}
.sContract-item-list{
   display: table;
   overflow: hidden;
   margin-left: 145px;
   margin-bottom: 16px;
}
.sContract-list-info{
   display: table-cell;
   vertical-align: middle;
}
.sContract-list-job{
   width: 41px;
}
.sContract-list-jobc{
   width: 60px;
}
.sContract-list-demand{
   width: 68px;
}
.sContract-list-demandc{
   width: 218px;
}
.sContract-list-workTime{
   width: 39px;
}
.sContract-list-workTimec{
   width: 110px;
}
.sContract-list-demandprice{
   width: 66px;
}
.sContract-list-demandpricec{
   width: 144px;
}
.sContract-list-wageprice{
   width: 66px;
}
.sContract-list-wagepricec{
   width: 115px;        
}
.sContract-wagepricec-text{
   width: 86px;
   border: 1px solid #c9c9c9;
}
/*选择套餐*/
.sContract-item-special{
   display: table;
   overflow: hidden;
   margin-left: 530px;
   margin-bottom: 16px;
}
.sContract-special-webtime{
   width: 39px;
}
.sContract-special-webtimec{
   width: 110px;
}
.sContract-special-webprice{
   width: 66px;
}
.sContract-special-webpricec{
   width: 144px;
}
.sContract-special-webwage{
   width: 66px;
}
.sContract-special-webwagec{
   width: 115px;
}
.sContract-webwagec-text{
   width: 86px;
   border: 1px solid #c9c9c9;
}
/* 合同详情结束@dongdong */
.sContract-item-submit{
  width: 96px;
  height: 32px;
  color: #fff;
  background: #00a7ea;
  font-size: 16px;
  border: none;
  cursor:pointer;
  margin: 32px 0 32px 140px;
}
.sContract-item-stop{
  margin: 32px 0 32px 40px;
}
/* 合同列表开始@dongdong */
.sContract-list-wrap{
   margin-top: 32px;
   
}
.sContract-list-box{
   width: 1280px;
   background: #f6f6f6;
   margin: 0 auto;
   font-size: 14px;
   overflow: hidden;
}
.sContract-box-conword{
   width: 80px;
   height: 16px;
   margin-top: 44px;
   margin-left: 24px;
   float: left;
}
.sContract-box-list{
   overflow: hidden;
   width: 1176px;
   margin-left: 78px;
   padding-top: 32px;
}
.sContract-list-item{
   padding: 0 20px;
   height: 40px;
   background: #e5e5e5;
   float: left;
   margin-right: 36px;
   margin-bottom: 24px;
   text-align: center;
   line-height: 40px;
   cursor: pointer;
}
.sContract-list-itemS{
  background: #fa0a48;
}
.sContract-list-item:hover{
   background: #00b5fe;
   color: #fff;
}
.sContract-list-cur{
   background: #00a7ea;
   color: #fff;
}
.sContract-list-modify{
   width: 96px;
   height: 32px;
   background: #00a7ea;
   border: none;
   color: #fff;
   cursor:pointer;
   font-size: 16px;
   margin: 8px auto 20px 100px;
}
/* 合同列表结束@dongdong */
</style>
<div class="demand-body">
    <form id='J_sContract_form' action="/system/sContract/create" method="post">
       <input class="J_sContract_form" type="hidden" name="data" value="">
       <input class="J_sContract_pid" type="hidden" name="pact_id" value="{{$first_pact->id}}">
       <input class="token" name="_token" type="hidden" value="{{csrf_token()}}">
       <div class="sContract-box J_sContract_box" id="anchor">
            <div class="sContract-box-nametime J_sContract_nametime" pactId="{{$first_pact->id}}">
                <div class="sContract-nametime-name"><!-- 合同名字 -->
                   <p class="sContract-name-p">合同:</p>
                   <input type="text" maxlength="17" class="sContract-name-text J_sContract_name" placeholder="{{$first_pact->Name}}" />
                </div>
                <div class="sContract-nametime-time"><!-- 有效期 -->
                   <p class="sContract-time-p">有效期:</p>
                   <input class="sContract-time-start J_time_start J_sContract_date" type="text" value="{{$validity[0]}}" disabled>
                   <p class="sContract-time-conn">-</p>
                   <input class="sContract-time-end J_time_end J_sContract_date" type="text" value="{{$validity[1]}}" disabled>
                </div>
            </div>
            <div class="sContract-box-item J_sContract_item">
            @foreach($first_pacttype as $val)
              @if($val->Type==2)
                <div class="J_sContract_ubox" pacttypeid="{{$val->id}}" type="2">
                <ul class="sContract-item-list J_item_list">
                  <li class="sContract-list-info sContract-list-job"><!-- 工种 -->
                    工种:
                  </li>
                  <li class="sContract-list-info sContract-list-jobc"><!-- 工种 -->
                    设计
                  </li>
                  <li class="sContract-list-info sContract-list-demand"><!-- 需求类型 -->
                    需求类型:
                  </li>
                  <li class="sContract-list-info sContract-list-demandc"><!-- 需求类型 -->
                    {{$val->Name}}
                  </li>
                  <li class="sContract-list-info sContract-list-workTime"><!-- 工时 -->
                    工时:
                  </li>
                  <li class="sContract-list-info sContract-list-workTimec"><!-- 工时 -->
                    {{$val->UedWorktime}}H
                  </li>
                  <li class="sContract-list-info sContract-list-demandprice"><!-- 需求价格 -->
                    需求价格:
                  </li>
                  <li class="sContract-list-info sContract-list-demandpricec J_sContract_prices"><!-- 需求价格 -->
                    {{$val->UedPrice}}元
                  </li>
                  <li class="sContract-list-info sContract-list-wageprice"><!-- 提成价格 -->
                    提成价格:
                  </li>
                  <li class="sContract-list-info sContract-list-wagepricec"><!-- 提成价格 -->
                    <input type="text" maxlength="17" class="sContract-wagepricec-text J_sContract_wageprice J_sContract_price" placeholder="{{$val->UedCommission}}" /> 元
                  </li>
                </ul>
              </div>
              @elseif($val->Type==4)
              <div class="J_sContract_ubox" pacttypeid="{{$val->id}}" type="4">
                <ul class="sContract-item-list J_item_list">
                  <li class="sContract-list-info sContract-list-job"><!-- 工种 -->
                    工种:
                  </li>
                  <li class="sContract-list-info sContract-list-jobc"><!-- 工种 -->
                    开发
                  </li>
                  <li class="sContract-list-info sContract-list-demand"><!-- 需求类型 -->
                    需求类型:
                  </li>
                  <li class="sContract-list-info sContract-list-demandc"><!-- 需求类型 -->
                    {{$val->Name}}
                  </li>
                  <li class="sContract-list-info sContract-list-workTime"><!-- 工时 -->
                    工时:
                  </li>
                  <li class="sContract-list-info sContract-list-workTimec"><!-- 工时 -->
                    {{$val->KWorktime}}H
                  </li>
                  <li class="sContract-list-info sContract-list-demandprice"><!-- 需求价格 -->
                    需求价格:
                  </li>
                  <li class="sContract-list-info sContract-list-demandpricec J_sContract_prices"><!-- 需求价格 -->
                    {{$val->KPrice}}元
                  </li>
                  <li class="sContract-list-info sContract-list-wageprice"><!-- 提成价格 -->
                    <p class="sContract-wageprice-p J_wageprice_p">
                      提成价格:
                    </p>
                  </li>
                  <li class="sContract-list-info sContract-list-wagepricec"><!-- 提成价格 -->
                    <input type="text" class="sContract-wagepricec-text J_sContract_wageprice J_sContract_price" maxlength="17" placeholder="{{$val->KCommission}}"/> 元
                  </li>
                </ul>
              </div>
              @elseif($val->Type==6)
                <div class="J_sContract_ubox" pacttypeid="{{$val->id}}" type="6">
                <ul class="sContract-item-list J_item_list">
                  <li class="sContract-list-info sContract-list-job"><!-- 工种 -->
                    工种:
                  </li>
                  <li class="sContract-list-info sContract-list-jobc"><!-- 工种 -->
                    套餐
                  </li>
                  <li class="sContract-list-info sContract-list-demand"><!-- 需求类型 -->
                    需求类型:
                  </li>
                  <li class="sContract-list-info sContract-list-demandc"><!-- 需求类型 -->
                    {{$val->Name}}
                  </li>
                  <li class="sContract-list-info sContract-list-workTime"><!-- 工时 -->
                    工时:
                  </li>
                  <li class="sContract-list-info sContract-list-workTimec"><!-- 工时 -->
                    {{$val->UedWorktime}}H
                  </li>
                  <li class="sContract-list-info sContract-list-demandprice"><!-- 需求价格 -->
                    视觉价格:
                  </li>
                  <li class="sContract-list-info sContract-list-demandpricec J_sContract_prices"><!-- 需求价格 -->
                    {{$val->UedPrice}}元
                  </li>
                  <li class="sContract-list-info sContract-list-wageprice"><!-- 提成价格 -->
                    视觉提成:
                  </li>
                  <li class="sContract-list-info sContract-list-wagepricec"><!-- 提成价格 -->
                    <input type="text" class="sContract-wagepricec-text J_sContract_wageprice J_sContract_price" maxlength="17" placeholder="{{$val->UedCommission}}"/> 元
                  </li>
                </ul>
                <ul class="sContract-item-special J_sContract_special"><!-- 选择套餐 -->
                    <li class="sContract-list-info sContract-special-webtime"><!-- 前端工时 -->
                      工时:
                    </li>
                    <li class="sContract-list-info sContract-special-webtimec"><!-- 前端工时 -->
                        {{$val->KWorktime}}H
                    </li>
                    <li class="sContract-list-info sContract-special-webprice"><!-- 前端价格 -->
                      前端价格:
                    </li>
                    <li class="sContract-list-info sContract-special-webpricec J_sContract_prices"><!-- 前端价格 -->
                      {{$val->KPrice}}元
                    </li>
                    <li class="sContract-list-info sContract-special-webwage"><!-- 前端提成 -->
                      前端提成:
                    </li>
                    <li class="sContract-list-info sContract-special-webwagec"><!-- 前端提成 -->
                       <input type="text" class="sContract-webwagec-text J_sContract_webwage J_sContract_price" maxlength="17" placeholder="{{$val->KCommission}}"/> 元
                    </li>
                </ul>
              </div>
              @endif
            @endforeach
            </div>
           <input type="button" value="提交" class="sContract-item-submit J_sContract_submit" />
        </div>
    </form>
 
    <div class="sContract-list-wrap">
        <div class="sContract-list-box">
            <p class="sContract-box-conword">
                公司合同:
            </p>
            <ul class="sContract-box-list J_sContract_list">
                @foreach($c_pactList as $data)
                  @if($data->Del==1)
                    <li class="sContract-list-item J_sCom_item" pId="{{$data->id}}">{{$data->Name}}</li>
                  @else
                  <li class="sContract-list-item sContract-list-itemS J_sCom_item" pId="{{$data->id}}">{{$data->Name}}</li>
                  @endif
                @endforeach
            </ul>
            <a href="#anchor"><input class="sContract-list-modify J_sContract_add" type="button" name="" value="添加" /></a>
        </div>
    </div>
     
    <div class="sContract-list-wrap">
        <div class="sContract-list-box">
            <p class="sContract-box-conword">
                供应商合同:
            </p>
            <ul class="sContract-box-list J_sContract_list">
                @foreach($s_pactList as $data)
                  @if($data->Del==1)
                    <li class="sContract-list-item J_sSup_item" pId="{{$data->id}}" del="{{$data->Del}}">{{$data->Name}}</li>
                  @else
                    <li class="sContract-list-item sContract-list-itemS J_sSup_item" pId="{{$data->id}}" del="{{$data->Del}}">{{$data->Name}}</li>
                  @endif
                @endforeach
            </ul>
            <a href="#anchor"><input class="sContract-list-modify J_sContract_modify" type="button" name="" value="修改" /></a>
        </div>
    </div>
</div>
<script>
 window.onload = function() {
    $('.J_sCom_item').eq(0).addClass('sContract-list-cur');
    //提交
    var sContractSub = function(config){
        var _self = this;
        _self.config = $.extend({},config,sContractSub.config);
    }
    sContractSub.config = {
        regPRNTDecimals: /^[0-9]+(\.[0-9]{2})?$/,//验证有两位小数的正实数
        data: ''
    }
    sContractSub.prototype = {
        _init: function(){
            var _self = this;
        },
        _check: function(inputval){
            var _self=this;
            if (inputval.length>15) {
               return false;
            }
            else if(inputval == ''){
               return false;
            }
            else if(!_self.config.regPRNTDecimals.test(inputval)){
               return false;
            }
            else {
               return true;
            }
        },
        _focusout: function(){
            var _self = this;
            $('input').on('focusout',function(){
                if($('.J_sContract_name').val() == ''){
                    $('.J_sContract_name').css('border-color','red').addClass('red');
                }
                else{
                    $('.J_sContract_name').css('border-color','#c9c9c9').removeClass('red');
                };
                $('.J_sContract_price').each(function(i,v){
                  var price = $.trim($(v).val());
                  var prices = parseInt($.trim($(v).parent().parent().find('.J_sContract_prices').text()));
                  if(_self._check(price) == true){
                    if(prices-price>=0){
                      $(v).css('border-color','#c9c9c9').removeClass('red');
                    }
                    else{
                      $(v).css('border-color','red').addClass('red');
                    }
                  }
                  else{
                    $(v).css('border-color','red').addClass('red');
                  }
                })
            })
        },
        _sContractSub: function(){
            var _self = this;
            _self._focusout();
            $('.J_sContract_submit').on('click',function(){
                if($('.red').length==0 && $.trim($('.J_sContract_name').val()).length>0){
                    _self._data();
                    $('.J_sContract_pid').val($('.J_sContract_nametime').attr('pactid'));
                    $('.J_sContract_form').val(_self.config.data);
                    $('#J_sContract_form').submit();
                }   
                else{
                    console.log(0);
                }
            })
        },
        _data: function(){
            var _self = this;
            var name = $('.J_sContract_name').val();
            var pid = $('.J_sContract_name').parent().parent().attr('pactid');
            function getUtf8Length(str){
               if (str==""||str==null) 
                   return 0;
               var n = 0;
               len = 0;
               for (i = 0; i < str.length; i++) {
                   n = str.charCodeAt(i);
                   if (n <= 255) 
                       len += 1;
                   else
                       len += 3;
               }
               return len;
            }
            var falg = '';
            if($('#J_sContract_form').attr('action')=='/system/sContract/create'){
              flag = 1;
            }
            else{
              flag = 0;
            }
            var unamelength = getUtf8Length(name);
            var lens = $('.J_sContract_ubox').length;
            var pactTypei = '';
            $('.J_sContract_ubox').each(function(i,v){
                var pactTypes = new Array();
                var t = $(v).attr('type');
                var id = $(v).attr('pacttypeid');
                var ii;
                var pactTypeii;
                if(t==2){
                    pactTypes[0] = t;
                    pactTypes[1] = $(v).find('.J_sContract_wageprice').val();
                    if(flag == 1){
                      ii=3;
                      pactTypeii = '{i:0;s:'+ pactTypes[0].length +':"'+ pactTypes[0] +'";i:1;s:'+ id.length +':"'+ id +'";i:2;s:'+ pactTypes[1].length +':"'+ pactTypes[1] +'";}';
                    }
                    else{
                      ii=2;
                      pactTypeii = '{i:0;s:'+ pactTypes[0].length +':"'+ pactTypes[0] +'";i:1;s:'+ pactTypes[1].length +':"'+ pactTypes[1] +'";}';
                    }
                    
                }
                else if(t==4){
                    pactTypes[0] = t;
                    pactTypes[1] = $(v).find('.J_sContract_wageprice').val();
                    if(flag == 1){
                      ii=3;
                      pactTypeii = '{i:0;s:'+ pactTypes[0].length +':"'+ pactTypes[0] +'";i:1;s:'+ id.length +':"'+ id +'";i:2;s:'+ pactTypes[1].length +':"'+ pactTypes[1] +'";}';
                    }
                    else{
                      ii=2;
                      pactTypeii = '{i:0;s:'+ pactTypes[0].length +':"'+ pactTypes[0] +'";i:1;s:'+ pactTypes[1].length +':"'+ pactTypes[1] +'";}';
                    }
                }
                else{
                    pactTypes[0] = t;
                    pactTypes[1] = $(v).find('.J_sContract_wageprice').val();
                    pactTypes[2] = $(v).find('.J_sContract_webwage').val();
                    if(flag == 1){
                      ii=4;
                      pactTypeii = '{i:0;s:'+ pactTypes[0].length +':"'+ pactTypes[0] +'";i:1;s:'+ id.length +':"'+ id +'";i:2;s:'+ pactTypes[1].length +':"'+ pactTypes[1] +'";i:3;s:'+ pactTypes[2].length +':"'+ pactTypes[2] +'";}';
                    }
                    else{
                      ii=3;
                      pactTypeii = '{i:0;s:'+ pactTypes[0].length +':"'+ pactTypes[0] +'";i:1;s:'+ pactTypes[1].length +':"'+ pactTypes[1] +'";i:2;s:'+ pactTypes[2].length +':"'+ pactTypes[2] +'";}';
                    }
                }
                if(flag ==1){
                  pactTypei = pactTypei +'i:'+ i +';a:'+ ii +':'+ pactTypeii;
                }
                else{
                  pactTypei = pactTypei +'i:'+ id +';a:'+ ii +':'+ pactTypeii;
                }
            })
            _self.config.data = 'a:2:{s:4:"pact";a:2:{s:4:"name";s:'+ unamelength +':"'+ name +'";s:7:"pact_id";s:'+ pid.length +':"'+ pid +'";}s:9:"pact_type";a:'+ lens +':{' + pactTypei + '}}';
        }
    }
    var sContractSub1 =new sContractSub({});
    sContractSub1._sContractSub();
    //合同选择
    var contractChoose = function(config){
        var _self = this;
        _self.config = $.extend({},config,contractChoose.config);
    }

    contractChoose.config = {
      sContractStop: '<input type="button" value="停用" class="sContract-item-submit sContract-item-stop J_sContract_stop" />'
    }

    contractChoose.prototype = {
        _init: function(){
          var _self = this;
        },
        _contractChoose: function(){
          var _self = this;
          $('.J_sCom_item').on('click',function(e){
               _self._click(e);
          })
         _self._comAdd();
        },
        _click: function(e){
          var target = e.target;
          $('.sContract-list-cur').removeClass('sContract-list-cur');
          $(target).addClass('sContract-list-cur');
        },
        _comAdd: function(){
          var _self = this;
          $('.J_sContract_add').on('click',function(){
            if($('.sContract-list-cur').hasClass('J_sCom_item')){
              var pId = $('.sContract-list-cur').attr('pid');
              $('#J_sContract_form').attr('action','/system/sContract/create');
              $('.J_sContract_stop').remove();
              _self._edit(pId);
            }else{
              console.log('请选择公司合同');
            }
          })
        },
        _supChoose: function(){
          var _self = this;
          $('.J_sSup_item').on('click',function(e){
               _self._click(e);
               $('.J_sSup_item').each(function(i,v){
                if($(v).attr('del')==1){
                  //$(v).css('background','#e5e5e5');
                  //$('.sContract-list-cur').css('background','#00a7ea')
                }
                else{
                  //$(v).css('background','#fa0a48');
                  //$('.sContract-list-cur').css('background','#00a7ea')
                }
               })
          })
         _self._supEdit();
        },
        _supEdit: function(){
          var _self = this;
          $('.J_sContract_modify').on('click',function(){
            if($('.sContract-list-cur').hasClass('J_sSup_item')){
              var pId = $('.sContract-list-cur').attr('pid');
              var del = $('.sContract-list-cur').attr('del');
              $('#J_sContract_form').attr('action','/system/sContract/edit_form');
              $('.red').css('border-color','#c9c9c9').removeClass('red');
              $('.J_sContract_stop').remove();
              $('.J_sContract_submit').after(_self.config.sContractStop);
              if($('.sContract-list-cur').attr('del') == 1){
                $('.J_sContract_stop').val('停用').css('background','#fa0a48');
              }
              else{
                $('.J_sContract_stop').val('启用').css('background','#00a7ea');
              }
              _self._stop(pId,del);
              _self._sEdit(pId);
            }
            else{
              console.log('请选择供应商合同');
            }
          })
        },
        _stop: function(pId,del){
          $('.J_sContract_stop').on('click',function(){
            $.ajax({
              url: 'destroy',
              type: 'post',
              data: {
                  pact_id: pId,
                  pact_del: del,
                  _token : '{{csrf_token()}}'
              },
              success:function(data){
                if(data == 1){
                  if(del == 1){
                    $('.J_sContract_stop').val('启用').css('background','#00a7ea');
                    $('.sContract-list-cur').attr('del',0);
                    del = 0;
                  }
                  else{
                    $('.J_sContract_stop').val('停用').css('background','#fa0a48');
                    $('.sContract-list-cur').attr('del',1);
                    del = 1;
                  }
                }
                else{
                  console.log('操作失败');
                }
              }
            })
          });
        },
        _success: function(list){
          $('.J_sContract_name').val('');
            $('.J_sContract_name').attr('placeholder',list.Pact[0].Name);
            $('.J_sContract_name').parents('.J_sContract_nametime').attr('pactid',list.Pact[0].id);
            var date = list.Pact[0].Validity;
            var dateStart = date.split(',')[0];
            var dateEnd = date.split(',')[1];
            var UedCommission,KCommission;
            $('.J_time_start').val(dateStart);
            $('.J_time_end').val(dateEnd);
            $('.J_sContract_item').empty();
            if(list.PactType){
              var dlist = list.PactType;
              var flag = 1;
            }
            else{
              var dlist = list.SupPactType;
              flag = 0;
            }
            for(var i = 0;i<dlist.length;i++){
              if(flag == 1){
                UedCommission = dlist[i].UedCommission;
                KCommission = dlist[i].KCommission;
              }
              else{
                UedCommission = dlist[i].SupUedPrice;
                KCommission = dlist[i].SupKPrice;
              }
                if(dlist[i].Type == 2){
                    var str = '<div class="J_sContract_ubox" pactTypeId="'+ dlist[i].id +'" type="2">'+
                                '<ul class="sContract-item-list J_item_list">'+
                                  '<li class="sContract-list-info sContract-list-job">'+
                                    '工种:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-jobc" value="2">'+
                                    '设计'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demand">'+
                                    '需求类型:'+
                                  '</li>'+
                                 '<li class="sContract-list-info sContract-list-demandc">'+
                                     dlist[i].Name +
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-workTime">'+
                                    '工时:'+
                                  '</li>'+
                                 '<li class="sContract-list-info sContract-list-workTimec">'+
                                    dlist[i].UedWorktime +'H'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demandprice">'+
                                    '需求价格:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demandpricec J_sContract_prices">'+
                                    dlist[i].UedPrice +'元'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-wageprice">'+
                                    '提成价格:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-wagepricec">'+
                                    '<input type="text" class="sContract-wagepricec-text J_sContract_wageprice J_sContract_price" maxlength="17" placeholder="'+ UedCommission +'" /> 元'+
                                  '</li>'+
                                '</ul>'+
                              '</div>';
                }
                else if(dlist[i].Type == 4){
                    var str = '<div class="J_sContract_ubox" pactTypeId="'+ dlist[i].id +'" type="4">'+
                                '<ul class="sContract-item-list J_item_list">'+
                                  '<li class="sContract-list-info sContract-list-job">'+
                                    '工种:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-jobc" value="4">'+
                                    '开发'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demand">'+
                                    '需求类型:'+
                                  '</li>'+
                                 '<li class="sContract-list-info sContract-list-demandc">'+
                                     dlist[i].Name +
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-workTime">'+
                                    '工时:'+
                                  '</li>'+
                                 '<li class="sContract-list-info sContract-list-workTimec">'+
                                    dlist[i].KWorktime +'H'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demandprice">'+
                                    '需求价格:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demandpricec J_sContract_prices">'+
                                    dlist[i].KPrice +'元'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-wageprice">'+
                                    '提成价格:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-wagepricec">'+
                                    '<input type="text" class="sContract-wagepricec-text J_sContract_wageprice J_sContract_price" maxlength="17" placeholder="'+ KCommission +'" /> 元'+
                                  '</li>'+
                                '</ul>'+
                              '</div>';
                }
                else{
                    var str = '<div class="J_sContract_ubox" pactTypeId="'+ dlist[i].id +'" type="6">'+
                                '<ul class="sContract-item-list J_item_list">'+
                                  '<li class="sContract-list-info sContract-list-job">'+
                                    '工种:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-jobc" value="4">'+
                                    '开发'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demand">'+
                                    '需求类型:'+
                                  '</li>'+
                                 '<li class="sContract-list-info sContract-list-demandc">'+
                                     dlist[i].Name +
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-workTime">'+
                                    '工时:'+
                                  '</li>'+
                                 '<li class="sContract-list-info sContract-list-workTimec">'+
                                    dlist[i].UedWorktime +'H'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demandprice">'+
                                    '视觉价格:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-demandpricec J_sContract_prices">'+
                                    dlist[i].UedPrice +'元'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-wageprice">'+
                                    '视觉提成:'+
                                  '</li>'+
                                  '<li class="sContract-list-info sContract-list-wagepricec">'+
                                    '<input type="text" class="sContract-wagepricec-text J_sContract_wageprice J_sContract_price" maxlength="17" placeholder="'+ UedCommission +'" /> 元'+
                                  '</li>'+
                                '</ul>'+
                                '<ul class="sContract-item-special J_sContract_special">'+
                                    '<li class="sContract-list-info sContract-special-webtime">'+
                                      '工时:'+
                                    '</li>'+
                                    '<li class="sContract-list-info sContract-special-webtimec">'+
                                        dlist[i].KWorktime +'H'+
                                    '</li>'+
                                    '<li class="sContract-list-info sContract-special-webprice">'+
                                      '前端价格:'+
                                    '</li>'+
                                    '<li class="sContract-list-info sContract-special-webpricec J_sContract_prices">'+
                                      dlist[i].KPrice+'元'+
                                    '</li>'+
                                    '<li class="sContract-list-info sContract-special-webwage">'+
                                      '前端提成:'+
                                    '</li>'+
                                    '<li class="sContract-list-info sContract-special-webwagec">'+
                                       '<input type="text" class="sContract-webwagec-text J_sContract_webwage J_sContract_price" maxlength="17" placeholder="'+KCommission+'"/> 元'+
                                    '</li>'+
                                '</ul>'+
                              '</div>';
                }
                $('.J_sContract_item').append(str);
                sContractSub1._focusout();
                if(flag == 0){
                  $('.J_sContract_name').val($('.J_sContract_name').attr('placeholder'));
                  $('.J_sContract_price').each(function(i,v){
                    $(v).val($(v).attr('placeholder'));
                  });
                }
            }
        },
        _edit: function(pId){
            var _self = this;
            $.ajax({
                url: '/system/cContract/edit',
                type: 'post',
                data: {
                    pact_id:pId,
                    _token : '{{csrf_token()}}'
                },
                success:function(data){
                    var list = JSON.parse(data);
                    _self._success(list);
                }
            })
        },
        _sEdit: function(pId){
          var _self = this;
            $.ajax({
                url: 'edit',
                type: 'post',
                data: {
                    pact_id:pId,
                    _token : '{{csrf_token()}}'
                },
                success:function(data){
                    var list = JSON.parse(data);
                    _self._success(list);
                }
            })
        }
    }
    //供应商合同选择
    var contractChoose1 = new contractChoose({});
    contractChoose1._contractChoose();
    contractChoose1._supChoose();

 }
</script>
@endsection